package com.hfjyz.system.category.bean;

import java.util.ArrayList;
import java.util.List;

import com.hfjyz.base.bean.BaseBean;
import com.hfjyz.base.entity.CategoryEntity;

public class CategoryBean extends BaseBean {

    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 1856587305509109981L;
    private Integer id = null;
    private String categoryName = null;
    private String categoryRemark = null;
    private Integer categoryParent = null;

    public CategoryBean() {
    }

    public CategoryBean(CategoryEntity entity) {
        setId(entity.getId());
        setName(entity.getCategoryName());
        setRemark(entity.getCategoryRemark());
        setParent(entity.getCategoryParent());
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return categoryName;
    }

    public void setName(String categoryName) {
        this.categoryName = categoryName;
    }

    public String getRemark() {
        return categoryRemark;
    }

    public void setRemark(String categoryRemark) {
        this.categoryRemark = categoryRemark;
    }

    public Integer getParent() {
        return categoryParent;
    }

    public void setParent(Integer categoryParent) {
        this.categoryParent = categoryParent;
    }

    @Override
    public List<String> toJsonArray(int index) {
        List<String> result = new ArrayList<String>();
        result.add(String.valueOf(getId()));
        result.add(categoryName);
        result.add(categoryRemark);

        return result;
    }

    @Override
    public String validate() {
        List<String> errorList = new ArrayList<String>();
        if (categoryName.length() > 16) {
            errorList.add("分类名长度不能超过16");
        }
        if (categoryRemark.length() > 128) {
            errorList.add("分类名长度不能超过128");
        }
        return getErrMsgForUI(errorList);
    }
}
